#version 150


uniform sampler2D tDiffuse; 
uniform sampler2D tPosition;
uniform sampler2D tNormals;


void main( void )
{
	vec4 image = texture( tDiffuse, gl_TexCoord[0].xy );
	vec4 position = texture( tPosition, gl_TexCoord[0].xy );
	vec4 normal = texture( tNormals, gl_TexCoord[0].xy );
	
	vec4 cameraPosition = vec4(0.0, -1.0, 0.0, 0.0);
	
	vec4 lightPos = vec4(1, 1, 1, 0.0);
	vec4 lightDir = lightPos - position;
	vec4 lightColor = vec4(.5, .5, .5, 1.0);
	
	normal = normalize(normal);
	lightDir = normalize(lightDir);
	
	vec4 eyeDir = normalize(cameraPosition-position);
	vec4 vHalfVector = normalize(lightDir+eyeDir);
	
	//gl_FragColor = max(dot(normal,lightDir),0.0) * image * lightColor;// + pow(max(dot(normal,vHalfVector),0.0), 100) * 1.5;
	gl_FragColor = max(dot(normal,lightDir),0) * image * lightColor;
}
